package com.zmn.plat.services.impl.product.engineerexamineurl;

import java.util.List;
import java.util.Objects;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.zmn.plat.model.entity.product.engineerexamineurl.EngineerExamineUrl;
import com.zmn.plat.model.entity.product.engineerexamineurl.EngineerExamineUrlQuery;
import com.zmn.plat.persistence.interfaces.product.engineerexamineurl.EngineerExamineUrlDAO;
import com.zmn.plat.services.interfaces.product.engineerexamineurl.EngineerExamineUrlService;

import lombok.extern.slf4j.Slf4j;

/**
 * 描述: 工程师升级考试地址基础接口实现类
 *
 * @author tanghongjun
 * @since 2020-08-19 11:18:36
 **/
@Slf4j
@Service
public class EngineerExamineUrlServiceImpl implements EngineerExamineUrlService {

    private static final String TAG = "工程师升级考试地址基础服务接口";

    @Resource
    private EngineerExamineUrlDAO engineerExamineUrlDao;

    /**
     * 描述: 根据id查询数据
     *
     * @param relateId
     *            id
     * @author tanghongjun
     * @since 2020-08-19 11:18:36
     **/
    @Override
    public EngineerExamineUrl findById(Integer relateId) {

        if (Objects.isNull(relateId)) {
            log.error("[{}],根据id查询数据为null", TAG);
            return null;
        }
        return engineerExamineUrlDao.findById(relateId);
    }

    @Override
    public EngineerExamineUrl findByGroupId(Integer groupId) {
        if (Objects.isNull(groupId)) {
            log.error("[{}],根据groupId查询数据groupId为null", TAG);
            return null;
        }
        return engineerExamineUrlDao.findByGroupId(groupId);
    }

    /**
     * 描述: 按条件查询数据 支持分页
     *
     * @param query
     *            查询对象
     * @author tanghongjun
     * @since 2020-08-19 11:18:36
     **/
    @Override
    public List<EngineerExamineUrl> listPageByQuery(EngineerExamineUrlQuery query) {

        if (Objects.isNull(query)) {
            log.error("[{}],按条件查询数据,query为null", TAG);
            return null;
        }
        return engineerExamineUrlDao.listPageByQuery(query);
    }

    /**
     * 描述: 按条件查询数据 不支持分页
     *
     * @param query
     *            查询对象
     * @author tanghongjun
     * @since 2020-08-19 11:18:36
     **/
    @Override
    public List<EngineerExamineUrl> listByQuery(EngineerExamineUrlQuery query) {

        if (Objects.isNull(query)) {
            log.error("[{}],按条件查询数据,query为null", TAG);
            return null;
        }
        return engineerExamineUrlDao.listByQuery(query);
    }

    /**
     * 描述: 按条件查询数据 不支持分页
     *
     * @param query
     *            查询对象
     * @author tanghongjun
     * @since 2020-08-19 11:18:36
     **/
    @Override
    public Integer countByQuery(EngineerExamineUrlQuery query) {

        if (Objects.isNull(query)) {
            log.error("[{}],按条件统计数据,query为null", TAG);
            return null;
        }
        return engineerExamineUrlDao.countByQuery(query);
    }

    /**
     * 描述: 根据id修改数据 id为必传
     *
     * @param engineerExamineUrl
     *            待修改数据
     * @return java.lang.Integer
     * @author tanghongjun
     * @since 2020-08-19 11:18:36
     **/
    @Override
    public Integer updateByKey(EngineerExamineUrl engineerExamineUrl) {

        if (Objects.isNull(engineerExamineUrl.getRelateId())) {
            log.error("[{}],根据id修改数据,engineerExamineUrl为null", TAG);
            return null;
        }
        return engineerExamineUrlDao.updateByKey(engineerExamineUrl);
    }

    /**
     * 描述: 新增数据
     *
     * @param engineerExamineUrl
     *            待新增数据
     * @return java.lang.Integer 主键key
     * @author tanghongjun
     * @since 2020-08-19 11:18:36
     **/
    @Override
    public Integer insert(EngineerExamineUrl engineerExamineUrl) {

        if (Objects.isNull(engineerExamineUrl)) {
            log.error("[{}],新增数据,engineerExamineUrl为null", TAG);
            return null;
        }
        return engineerExamineUrlDao.insert(engineerExamineUrl);
    }

    /**
     * 描述: 根据主键删除数据
     *
     * @param relateId
     * @return: 执行结果码
     * @auther: tanghongjun
     * @since: 2020-08-19 11:18:36
     */
    @Override
    public Integer deleteByKey(Integer relateId) {

        if (Objects.isNull(relateId)) {
            log.error("[{}],根据id删除数据,relateId为null", TAG);
            return null;
        }
        return engineerExamineUrlDao.deleteByKey(relateId);
    }

}